import Field from 'winged/utils/wt-model-field'

export default {
	title: '影像',
	name: 'image',
	tableName: 'imaging_exam',
	single: false,
	query: {
		method: 'GET',
		url: 'doctor/patient/imaging/exam',
		transfer: true,
		pagination: true,
		extraParams: [
			'case_id',
		]
	},
    count: {
        method: 'GET',
        url: 'doctor/patient/imaging/exam/count',
        transfer: true,
        extraParams: [
            'case_id',
        ],
    },
	new: {
		method: 'POST',
		url: 'doctor/patient/imaging/exam',
		transfer: true,
		extraParams: [
			'case_id',
		]
	},
	update: {
		method: 'PUT',
		url: 'doctor/patient/imaging/exam',
		transfer: true
	},
	delete: {
		method: 'DELETE',
		url: 'doctor/patient/imaging/exam',
		transfer: true
	},
	id_field: {
		// 用于修改、删除操作的字段名
		name: 'exam_id',
	},
	fields: [
		{
			label: '类别',
			type: Field.types.select,
			query: {
				url: 'doctor/patient/imaging/exam/type',
				method: 'GET',
				transfer: true,
				value: '',
				allowAdd: false
			},
			display: true,
			summary: true,
			name: 'exam_type',
			tableName: 'examType',
			rules: [
				{ required: true, message: '请选择影像类型', trigger: 'change' }
			]
		}, {
			label: '部位',
			type: Field.types.autocomplete,
			query: {
				url: 'doctor/patient/imaging/exam/position',
				method: 'GET',
				transfer: true,
				pagination: true,
				useAutoFilter: true,
				allowAdd: true,
				addMethod: 'POST',
				addParam: 'exam_position',
				allowEmptyQuery: true,
				filterParam: 'position_name',
				label: 'examPosition',
				value: 'examPosition',
			},
			display: true,
			summary: true,
			name: 'exam_position',
			tableName: 'examPosition',
			rules: [
				{ required: true, message: '请选择影像部位', trigger: 'change' }
			],
		}, {
			label: '日期',
			type: Field.types.date,
			display: true,
			name: 'exam_date',
			tableName: 'examDate',
			rules: [
				{ type: 'date', required: true, message: '请选择影像日期', trigger: 'change' }
			]
		}, {
			label: '状态',
			type: Field.types.select,
			options: [
				{
					label: '手术前',
					value: 'PRE_OPERATION'
				}, {
					label: '手术中',
					value: 'INTRA_OPERATION'
				}, {
					label: '手术后',
					value: 'POST_OPERATION',
				}
			],
			display: true,
			summary: true,
			formSize: 'small',
			name: 'exam_point_in_time',
			tableName: 'examPointInTime',
			/*conditions: [{
				value: 'POST_OPERATION',
				fields: ['afterSurgeryYear', 'afterSurgeryMonth', 'afterSurgeryDay'],
				appendComponent: 'wt-case-image-time-calculator',
			}],*/
			rules:[
				{ required: true, message: '请选择状态', trigger: 'change' }
			]
		}, {
			label: '备注',
			type: Field.types.textarea,
			display: false,
			name: 'comment',
			tableName: 'comment'
		}, {
			label: '影像',
			type: Field.types.images,
			display: true,
			summary: true,
			name: 'image_urls',
			tableName: 'examImages',
			uploadByComponent: true,
			saveAsJson: true,
			preSubmit: true,
		}/*, {
			type: Field.types.number,
			conditional: true,
			display: false,
			unit: '年',
			formSize: 'mini',
			name: 'after_surgery_year',
			tableName: 'afterSurgeryYear',
			rules: [
				{ type: 'number', min: 0, message: '请输入不小于零的数字', trigger: 'change' }
			]
		}, {
			type: Field.types.number,
			conditional: true,
			display: false,
			unit: '月',
			formSize: 'mini',
			name: 'after_surgery_month',
			tableName: 'afterSurgeryMonth',
			rules: [
				{ type: 'number', min: 0,  message: '请输入不小于零的数字', trigger: 'change' }
			]
		}, {
			type: Field.types.number,
			conditional: true,
			display: false,
			unit: '天',
			formSize: 'mini',
			name: 'after_surgery_day',
			tableName: 'afterSurgeryDay',
			rules: [
				{ type: 'number', min: 0, message: '请输入不小于零的数字', trigger: 'change' }
			]
		}*/
	]
};